#line 1 "D:\\NUC029xAN_BSPv3.00.003\\Library\\StdDriver\\src\\retarget.c"
 









 


#line 1 "C:\\Keil_v5\\ARM\\ARMCC\\Bin\\..\\include\\stdio.h"
 
 
 





 






 







 




  
 








#line 47 "C:\\Keil_v5\\ARM\\ARMCC\\Bin\\..\\include\\stdio.h"


  



    typedef unsigned int size_t;    









 
 

 



    typedef struct __va_list __va_list;






   




 




typedef struct __fpos_t_struct {
    unsigned __int64 __pos;
    



 
    struct {
        unsigned int __state1, __state2;
    } __mbstate;
} fpos_t;
   


 


   

 

typedef struct __FILE FILE;
   






 

#line 136 "C:\\Keil_v5\\ARM\\ARMCC\\Bin\\..\\include\\stdio.h"


extern FILE __stdin, __stdout, __stderr;
extern FILE *__aeabi_stdin, *__aeabi_stdout, *__aeabi_stderr;

#line 166 "C:\\Keil_v5\\ARM\\ARMCC\\Bin\\..\\include\\stdio.h"
    

    

    





     



   


 


   


 

   



 

   


 




   


 





    


 






extern __declspec(__nothrow) int remove(const char *  ) __attribute__((__nonnull__(1)));
   





 
extern __declspec(__nothrow) int rename(const char *  , const char *  ) __attribute__((__nonnull__(1,2)));
   








 
extern __declspec(__nothrow) FILE *tmpfile(void);
   




 
extern __declspec(__nothrow) char *tmpnam(char *  );
   











 

extern __declspec(__nothrow) int fclose(FILE *  ) __attribute__((__nonnull__(1)));
   







 
extern __declspec(__nothrow) int fflush(FILE *  );
   







 
extern __declspec(__nothrow) FILE *fopen(const char * __restrict  ,
                           const char * __restrict  ) __attribute__((__nonnull__(1,2)));
   








































 
extern __declspec(__nothrow) FILE *freopen(const char * __restrict  ,
                    const char * __restrict  ,
                    FILE * __restrict  ) __attribute__((__nonnull__(2,3)));
   








 
extern __declspec(__nothrow) void setbuf(FILE * __restrict  ,
                    char * __restrict  ) __attribute__((__nonnull__(1)));
   




 
extern __declspec(__nothrow) int setvbuf(FILE * __restrict  ,
                   char * __restrict  ,
                   int  , size_t  ) __attribute__((__nonnull__(1)));
   















 
#pragma __printf_args
extern __declspec(__nothrow) int fprintf(FILE * __restrict  ,
                    const char * __restrict  , ...) __attribute__((__nonnull__(1,2)));
   


















 
#pragma __printf_args
extern __declspec(__nothrow) int _fprintf(FILE * __restrict  ,
                     const char * __restrict  , ...) __attribute__((__nonnull__(1,2)));
   



 
#pragma __printf_args
extern __declspec(__nothrow) int printf(const char * __restrict  , ...) __attribute__((__nonnull__(1)));
   




 
#pragma __printf_args
extern __declspec(__nothrow) int _printf(const char * __restrict  , ...) __attribute__((__nonnull__(1)));
   



 
#pragma __printf_args
extern __declspec(__nothrow) int sprintf(char * __restrict  , const char * __restrict  , ...) __attribute__((__nonnull__(1,2)));
   






 
#pragma __printf_args
extern __declspec(__nothrow) int _sprintf(char * __restrict  , const char * __restrict  , ...) __attribute__((__nonnull__(1,2)));
   



 

#pragma __printf_args
extern __declspec(__nothrow) int __ARM_snprintf(char * __restrict  , size_t  ,
                     const char * __restrict  , ...) __attribute__((__nonnull__(3)));


#pragma __printf_args
extern __declspec(__nothrow) int snprintf(char * __restrict  , size_t  ,
                     const char * __restrict  , ...) __attribute__((__nonnull__(3)));
   















 

#pragma __printf_args
extern __declspec(__nothrow) int _snprintf(char * __restrict  , size_t  ,
                      const char * __restrict  , ...) __attribute__((__nonnull__(3)));
   



 
#pragma __scanf_args
extern __declspec(__nothrow) int fscanf(FILE * __restrict  ,
                    const char * __restrict  , ...) __attribute__((__nonnull__(1,2)));
   






























 
#pragma __scanf_args
extern __declspec(__nothrow) int _fscanf(FILE * __restrict  ,
                     const char * __restrict  , ...) __attribute__((__nonnull__(1,2)));
   



 
#pragma __scanf_args
extern __declspec(__nothrow) int scanf(const char * __restrict  , ...) __attribute__((__nonnull__(1)));
   






 
#pragma __scanf_args
extern __declspec(__nothrow) int _scanf(const char * __restrict  , ...) __attribute__((__nonnull__(1)));
   



 
#pragma __scanf_args
extern __declspec(__nothrow) int sscanf(const char * __restrict  ,
                    const char * __restrict  , ...) __attribute__((__nonnull__(1,2)));
   








 
#pragma __scanf_args
extern __declspec(__nothrow) int _sscanf(const char * __restrict  ,
                     const char * __restrict  , ...) __attribute__((__nonnull__(1,2)));
   



 

 
extern __declspec(__nothrow) int vfscanf(FILE * __restrict  , const char * __restrict  , __va_list) __attribute__((__nonnull__(1,2)));
extern __declspec(__nothrow) int vscanf(const char * __restrict  , __va_list) __attribute__((__nonnull__(1)));
extern __declspec(__nothrow) int vsscanf(const char * __restrict  , const char * __restrict  , __va_list) __attribute__((__nonnull__(1,2)));

extern __declspec(__nothrow) int _vfscanf(FILE * __restrict  , const char * __restrict  , __va_list) __attribute__((__nonnull__(1,2)));
extern __declspec(__nothrow) int _vscanf(const char * __restrict  , __va_list) __attribute__((__nonnull__(1)));
extern __declspec(__nothrow) int _vsscanf(const char * __restrict  , const char * __restrict  , __va_list) __attribute__((__nonnull__(1,2)));
extern __declspec(__nothrow) int __ARM_vsscanf(const char * __restrict  , const char * __restrict  , __va_list) __attribute__((__nonnull__(1,2)));

extern __declspec(__nothrow) int vprintf(const char * __restrict  , __va_list  ) __attribute__((__nonnull__(1)));
   





 
extern __declspec(__nothrow) int _vprintf(const char * __restrict  , __va_list  ) __attribute__((__nonnull__(1)));
   



 
extern __declspec(__nothrow) int vfprintf(FILE * __restrict  ,
                    const char * __restrict  , __va_list  ) __attribute__((__nonnull__(1,2)));
   






 
extern __declspec(__nothrow) int vsprintf(char * __restrict  ,
                     const char * __restrict  , __va_list  ) __attribute__((__nonnull__(1,2)));
   






 
extern __declspec(__nothrow) int __ARM_vsnprintf(char * __restrict  , size_t  ,
                     const char * __restrict  , __va_list  ) __attribute__((__nonnull__(3)));

extern __declspec(__nothrow) int vsnprintf(char * __restrict  , size_t  ,
                     const char * __restrict  , __va_list  ) __attribute__((__nonnull__(3)));
   







 

extern __declspec(__nothrow) int _vsprintf(char * __restrict  ,
                      const char * __restrict  , __va_list  ) __attribute__((__nonnull__(1,2)));
   



 
extern __declspec(__nothrow) int _vfprintf(FILE * __restrict  ,
                     const char * __restrict  , __va_list  ) __attribute__((__nonnull__(1,2)));
   



 
extern __declspec(__nothrow) int _vsnprintf(char * __restrict  , size_t  ,
                      const char * __restrict  , __va_list  ) __attribute__((__nonnull__(3)));
   



 

#pragma __printf_args
extern __declspec(__nothrow) int asprintf(char **  , const char * __restrict  , ...) __attribute__((__nonnull__(2)));
extern __declspec(__nothrow) int vasprintf(char **  , const char * __restrict  , __va_list  ) __attribute__((__nonnull__(2)));

#pragma __printf_args
extern __declspec(__nothrow) int __ARM_asprintf(char **  , const char * __restrict  , ...) __attribute__((__nonnull__(2)));
extern __declspec(__nothrow) int __ARM_vasprintf(char **  , const char * __restrict  , __va_list  ) __attribute__((__nonnull__(2)));
   








 

extern __declspec(__nothrow) int fgetc(FILE *  ) __attribute__((__nonnull__(1)));
   







 
extern __declspec(__nothrow) char *fgets(char * __restrict  , int  ,
                    FILE * __restrict  ) __attribute__((__nonnull__(1,3)));
   










 
extern __declspec(__nothrow) int fputc(int  , FILE *  ) __attribute__((__nonnull__(2)));
   







 
extern __declspec(__nothrow) int fputs(const char * __restrict  , FILE * __restrict  ) __attribute__((__nonnull__(1,2)));
   




 
extern __declspec(__nothrow) int getc(FILE *  ) __attribute__((__nonnull__(1)));
   







 




    extern __declspec(__nothrow) int (getchar)(void);

   





 
extern __declspec(__nothrow) char *gets(char *  ) __attribute__((__nonnull__(1)));
   









 
extern __declspec(__nothrow) int putc(int  , FILE *  ) __attribute__((__nonnull__(2)));
   





 




    extern __declspec(__nothrow) int (putchar)(int  );

   



 
extern __declspec(__nothrow) int puts(const char *  ) __attribute__((__nonnull__(1)));
   





 
extern __declspec(__nothrow) int ungetc(int  , FILE *  ) __attribute__((__nonnull__(2)));
   






















 

extern __declspec(__nothrow) size_t fread(void * __restrict  ,
                    size_t  , size_t  , FILE * __restrict  ) __attribute__((__nonnull__(1,4)));
   











 

extern __declspec(__nothrow) size_t __fread_bytes_avail(void * __restrict  ,
                    size_t  , FILE * __restrict  ) __attribute__((__nonnull__(1,3)));
   











 

extern __declspec(__nothrow) size_t fwrite(const void * __restrict  ,
                    size_t  , size_t  , FILE * __restrict  ) __attribute__((__nonnull__(1,4)));
   







 

extern __declspec(__nothrow) int fgetpos(FILE * __restrict  , fpos_t * __restrict  ) __attribute__((__nonnull__(1,2)));
   








 
extern __declspec(__nothrow) int fseek(FILE *  , long int  , int  ) __attribute__((__nonnull__(1)));
   














 
extern __declspec(__nothrow) int fsetpos(FILE * __restrict  , const fpos_t * __restrict  ) __attribute__((__nonnull__(1,2)));
   










 
extern __declspec(__nothrow) long int ftell(FILE *  ) __attribute__((__nonnull__(1)));
   











 
extern __declspec(__nothrow) void rewind(FILE *  ) __attribute__((__nonnull__(1)));
   





 

extern __declspec(__nothrow) void clearerr(FILE *  ) __attribute__((__nonnull__(1)));
   




 

extern __declspec(__nothrow) int feof(FILE *  ) __attribute__((__nonnull__(1)));
   


 
extern __declspec(__nothrow) int ferror(FILE *  ) __attribute__((__nonnull__(1)));
   


 
extern __declspec(__nothrow) void perror(const char *  );
   









 

extern __declspec(__nothrow) int _fisatty(FILE *   ) __attribute__((__nonnull__(1)));
    
 

extern __declspec(__nothrow) void __use_no_semihosting_swi(void);
extern __declspec(__nothrow) void __use_no_semihosting(void);
    





 











#line 1021 "C:\\Keil_v5\\ARM\\ARMCC\\Bin\\..\\include\\stdio.h"



 

#line 15 "D:\\NUC029xAN_BSPv3.00.003\\Library\\StdDriver\\src\\retarget.c"
#line 1 "D:\\NUC029xAN_BSPv3.00.003\\Library\\Device\\Nuvoton\\NUC029xAN\\Include\\NUC029xAN.h"
 









 


















 










 



 
typedef enum IRQn
{
     
    NonMaskableInt_IRQn       = -14,       
    HardFault_IRQn            = -13,       
    SVCall_IRQn               = -5,        
    PendSV_IRQn               = -2,        
    SysTick_IRQn              = -1,        

     
    BOD_IRQn                  = 0,         
    WDT_IRQn                  = 1,         
    EINT0_IRQn                = 2,         
    EINT1_IRQn                = 3,         
    GPIO_P0P1_IRQn            = 4,         
    GPIO_P2P3P4_IRQn          = 5,         
    PWMA_IRQn                 = 6,         
    PWMB_IRQn                 = 7,         
    TMR0_IRQn                 = 8,         
    TMR1_IRQn                 = 9,         
    TMR2_IRQn                 = 10,        
    TMR3_IRQn                 = 11,        
    UART0_IRQn                = 12,        
    UART1_IRQn                = 13,        
    SPI0_IRQn                 = 14,        
    SPI1_IRQn                 = 15,        
    I2C0_IRQn                 = 18,        
    I2C1_IRQn                 = 19,        
    ACMP01_IRQn               = 25,        
    ACMP23_IRQn               = 26,        
    PWRWU_IRQn                = 28,        
    ADC_IRQn                  = 29         

} IRQn_Type;






 

 





#line 1 "D:\\NUC029xAN_BSPv3.00.003\\Library\\CMSIS\\Include\\core_cm0.h"
 




















 













 












 




 


 

 













#line 89 "D:\\NUC029xAN_BSPv3.00.003\\Library\\CMSIS\\Include\\core_cm0.h"


 







#line 114 "D:\\NUC029xAN_BSPv3.00.003\\Library\\CMSIS\\Include\\core_cm0.h"

#line 1 "C:\\Keil_v5\\ARM\\ARMCC\\Bin\\..\\include\\stdint.h"
 
 





 









     
#line 27 "C:\\Keil_v5\\ARM\\ARMCC\\Bin\\..\\include\\stdint.h"
     











#line 46 "C:\\Keil_v5\\ARM\\ARMCC\\Bin\\..\\include\\stdint.h"





 

     

     
typedef   signed          char int8_t;
typedef   signed short     int int16_t;
typedef   signed           int int32_t;
typedef   signed       __int64 int64_t;

     
typedef unsigned          char uint8_t;
typedef unsigned short     int uint16_t;
typedef unsigned           int uint32_t;
typedef unsigned       __int64 uint64_t;

     

     
     
typedef   signed          char int_least8_t;
typedef   signed short     int int_least16_t;
typedef   signed           int int_least32_t;
typedef   signed       __int64 int_least64_t;

     
typedef unsigned          char uint_least8_t;
typedef unsigned short     int uint_least16_t;
typedef unsigned           int uint_least32_t;
typedef unsigned       __int64 uint_least64_t;

     

     
typedef   signed           int int_fast8_t;
typedef   signed           int int_fast16_t;
typedef   signed           int int_fast32_t;
typedef   signed       __int64 int_fast64_t;

     
typedef unsigned           int uint_fast8_t;
typedef unsigned           int uint_fast16_t;
typedef unsigned           int uint_fast32_t;
typedef unsigned       __int64 uint_fast64_t;

     




typedef   signed           int intptr_t;
typedef unsigned           int uintptr_t;


     
typedef   signed     long long intmax_t;
typedef unsigned     long long uintmax_t;




     

     





     





     





     

     





     





     





     

     





     





     





     

     






     






     






     

     


     


     


     

     
#line 216 "C:\\Keil_v5\\ARM\\ARMCC\\Bin\\..\\include\\stdint.h"

     



     






     
    
 



#line 241 "C:\\Keil_v5\\ARM\\ARMCC\\Bin\\..\\include\\stdint.h"

     







     










     











#line 305 "C:\\Keil_v5\\ARM\\ARMCC\\Bin\\..\\include\\stdint.h"






 
#line 116 "D:\\NUC029xAN_BSPv3.00.003\\Library\\CMSIS\\Include\\core_cm0.h"
#line 1 "D:\\NUC029xAN_BSPv3.00.003\\Library\\CMSIS\\Include\\core_cmInstr.h"
 




















 






 


 



 


 









 







 







 






 








 







 







 









 









 
__attribute__((section(".rev16_text"))) static __inline __asm uint32_t __REV16(uint32_t value)
{
  rev16 r0, r0
  bx lr
}








 
__attribute__((section(".revsh_text"))) static __inline __asm int32_t __REVSH(int32_t value)
{
  revsh r0, r0
  bx lr
}









 



#line 268 "D:\\NUC029xAN_BSPv3.00.003\\Library\\CMSIS\\Include\\core_cmInstr.h"



#line 619 "D:\\NUC029xAN_BSPv3.00.003\\Library\\CMSIS\\Include\\core_cmInstr.h"

   

   

#line 117 "D:\\NUC029xAN_BSPv3.00.003\\Library\\CMSIS\\Include\\core_cm0.h"
#line 1 "D:\\NUC029xAN_BSPv3.00.003\\Library\\CMSIS\\Include\\core_cmFunc.h"
 




















 






 

 



 


 





 
 






 
static __inline uint32_t __get_CONTROL(void)
{
  register uint32_t __regControl         __asm("control");
  return(__regControl);
}







 
static __inline void __set_CONTROL(uint32_t control)
{
  register uint32_t __regControl         __asm("control");
  __regControl = control;
}







 
static __inline uint32_t __get_IPSR(void)
{
  register uint32_t __regIPSR          __asm("ipsr");
  return(__regIPSR);
}







 
static __inline uint32_t __get_APSR(void)
{
  register uint32_t __regAPSR          __asm("apsr");
  return(__regAPSR);
}







 
static __inline uint32_t __get_xPSR(void)
{
  register uint32_t __regXPSR          __asm("xpsr");
  return(__regXPSR);
}







 
static __inline uint32_t __get_PSP(void)
{
  register uint32_t __regProcessStackPointer  __asm("psp");
  return(__regProcessStackPointer);
}







 
static __inline void __set_PSP(uint32_t topOfProcStack)
{
  register uint32_t __regProcessStackPointer  __asm("psp");
  __regProcessStackPointer = topOfProcStack;
}







 
static __inline uint32_t __get_MSP(void)
{
  register uint32_t __regMainStackPointer     __asm("msp");
  return(__regMainStackPointer);
}







 
static __inline void __set_MSP(uint32_t topOfMainStack)
{
  register uint32_t __regMainStackPointer     __asm("msp");
  __regMainStackPointer = topOfMainStack;
}







 
static __inline uint32_t __get_PRIMASK(void)
{
  register uint32_t __regPriMask         __asm("primask");
  return(__regPriMask);
}







 
static __inline void __set_PRIMASK(uint32_t priMask)
{
  register uint32_t __regPriMask         __asm("primask");
  __regPriMask = (priMask);
}


#line 260 "D:\\NUC029xAN_BSPv3.00.003\\Library\\CMSIS\\Include\\core_cmFunc.h"


#line 296 "D:\\NUC029xAN_BSPv3.00.003\\Library\\CMSIS\\Include\\core_cmFunc.h"


#line 615 "D:\\NUC029xAN_BSPv3.00.003\\Library\\CMSIS\\Include\\core_cmFunc.h"

 

   

#line 118 "D:\\NUC029xAN_BSPv3.00.003\\Library\\CMSIS\\Include\\core_cm0.h"








 
#line 143 "D:\\NUC029xAN_BSPv3.00.003\\Library\\CMSIS\\Include\\core_cm0.h"

 






 
#line 159 "D:\\NUC029xAN_BSPv3.00.003\\Library\\CMSIS\\Include\\core_cm0.h"

 










 


 





 


 
typedef union
{
  struct
  {

    uint32_t _reserved0:27;               





    uint32_t Q:1;                         
    uint32_t V:1;                         
    uint32_t C:1;                         
    uint32_t Z:1;                         
    uint32_t N:1;                         
  } b;                                    
  uint32_t w;                             
} APSR_Type;



 
typedef union
{
  struct
  {
    uint32_t ISR:9;                       
    uint32_t _reserved0:23;               
  } b;                                    
  uint32_t w;                             
} IPSR_Type;



 
typedef union
{
  struct
  {
    uint32_t ISR:9;                       

    uint32_t _reserved0:15;               





    uint32_t T:1;                         
    uint32_t IT:2;                        
    uint32_t Q:1;                         
    uint32_t V:1;                         
    uint32_t C:1;                         
    uint32_t Z:1;                         
    uint32_t N:1;                         
  } b;                                    
  uint32_t w;                             
} xPSR_Type;



 
typedef union
{
  struct
  {
    uint32_t nPRIV:1;                     
    uint32_t SPSEL:1;                     
    uint32_t FPCA:1;                      
    uint32_t _reserved0:29;               
  } b;                                    
  uint32_t w;                             
} CONTROL_Type;

 






 


 
typedef struct
{
  volatile uint32_t ISER[1];                  
       uint32_t RESERVED0[31];
  volatile uint32_t ICER[1];                  
       uint32_t RSERVED1[31];
  volatile uint32_t ISPR[1];                  
       uint32_t RESERVED2[31];
  volatile uint32_t ICPR[1];                  
       uint32_t RESERVED3[31];
       uint32_t RESERVED4[64];
  volatile uint32_t IP[8];                    
}  NVIC_Type;

 






 


 
typedef struct
{
  volatile const  uint32_t CPUID;                    
  volatile uint32_t ICSR;                     
       uint32_t RESERVED0;
  volatile uint32_t AIRCR;                    
  volatile uint32_t SCR;                      
  volatile uint32_t CCR;                      
       uint32_t RESERVED1;
  volatile uint32_t SHP[2];                   
  volatile uint32_t SHCSR;                    
} SCB_Type;

 















 



























 















 









 






 



 






 


 
typedef struct
{
  volatile uint32_t CTRL;                     
  volatile uint32_t LOAD;                     
  volatile uint32_t VAL;                      
  volatile const  uint32_t CALIB;                    
} SysTick_Type;

 












 



 



 









 








 
 






 

 










 









 

 



 




 

 
 










 
static __inline void NVIC_EnableIRQ(IRQn_Type IRQn)
{
  ((NVIC_Type *) ((0xE000E000UL) + 0x0100UL) )->ISER[0] = (1 << ((uint32_t)(IRQn) & 0x1F));
}







 
static __inline void NVIC_DisableIRQ(IRQn_Type IRQn)
{
  ((NVIC_Type *) ((0xE000E000UL) + 0x0100UL) )->ICER[0] = (1 << ((uint32_t)(IRQn) & 0x1F));
}











 
static __inline uint32_t NVIC_GetPendingIRQ(IRQn_Type IRQn)
{
  return((uint32_t) ((((NVIC_Type *) ((0xE000E000UL) + 0x0100UL) )->ISPR[0] & (1 << ((uint32_t)(IRQn) & 0x1F)))?1:0));
}







 
static __inline void NVIC_SetPendingIRQ(IRQn_Type IRQn)
{
  ((NVIC_Type *) ((0xE000E000UL) + 0x0100UL) )->ISPR[0] = (1 << ((uint32_t)(IRQn) & 0x1F));
}







 
static __inline void NVIC_ClearPendingIRQ(IRQn_Type IRQn)
{
  ((NVIC_Type *) ((0xE000E000UL) + 0x0100UL) )->ICPR[0] = (1 << ((uint32_t)(IRQn) & 0x1F));  
}










 
static __inline void NVIC_SetPriority(IRQn_Type IRQn, uint32_t priority)
{
  if(IRQn < 0) {
    ((SCB_Type *) ((0xE000E000UL) + 0x0D00UL) )->SHP[( ((((uint32_t)(IRQn) & 0x0F)-8) >> 2) )] = (((SCB_Type *) ((0xE000E000UL) + 0x0D00UL) )->SHP[( ((((uint32_t)(IRQn) & 0x0F)-8) >> 2) )] & ~(0xFF << ( (((uint32_t)(IRQn) ) & 0x03) * 8 ))) |
        (((priority << (8 - 2)) & 0xFF) << ( (((uint32_t)(IRQn) ) & 0x03) * 8 )); }
  else {
    ((NVIC_Type *) ((0xE000E000UL) + 0x0100UL) )->IP[( ((uint32_t)(IRQn) >> 2) )] = (((NVIC_Type *) ((0xE000E000UL) + 0x0100UL) )->IP[( ((uint32_t)(IRQn) >> 2) )] & ~(0xFF << ( (((uint32_t)(IRQn) ) & 0x03) * 8 ))) |
        (((priority << (8 - 2)) & 0xFF) << ( (((uint32_t)(IRQn) ) & 0x03) * 8 )); }
}












 
static __inline uint32_t NVIC_GetPriority(IRQn_Type IRQn)
{

  if(IRQn < 0) {
    return((uint32_t)((((SCB_Type *) ((0xE000E000UL) + 0x0D00UL) )->SHP[( ((((uint32_t)(IRQn) & 0x0F)-8) >> 2) )] >> ( (((uint32_t)(IRQn) ) & 0x03) * 8 ) ) >> (8 - 2)));  }  
  else {
    return((uint32_t)((((NVIC_Type *) ((0xE000E000UL) + 0x0100UL) )->IP[ ( ((uint32_t)(IRQn) >> 2) )] >> ( (((uint32_t)(IRQn) ) & 0x03) * 8 ) ) >> (8 - 2)));  }  
}





 
static __inline void NVIC_SystemReset(void)
{
  __dsb(0xF);                                                     
 
  ((SCB_Type *) ((0xE000E000UL) + 0x0D00UL) )->AIRCR  = ((0x5FA << 16)      |
                 (1UL << 2));
  __dsb(0xF);                                                      
  while(1);                                                     
}

 



 




 

















 
static __inline uint32_t SysTick_Config(uint32_t ticks)
{
  if (ticks > (0xFFFFFFUL << 0))  return (1);             

  ((SysTick_Type *) ((0xE000E000UL) + 0x0010UL) )->LOAD  = (ticks & (0xFFFFFFUL << 0)) - 1;       
  NVIC_SetPriority (SysTick_IRQn, (1<<2) - 1);   
  ((SysTick_Type *) ((0xE000E000UL) + 0x0010UL) )->VAL   = 0;                                           
  ((SysTick_Type *) ((0xE000E000UL) + 0x0010UL) )->CTRL  = (1UL << 2) |
                   (1UL << 1)   |
                   (1UL << 0);                     
  return (0);                                                   
}



 








   

#line 95 "D:\\NUC029xAN_BSPv3.00.003\\Library\\Device\\Nuvoton\\NUC029xAN\\Include\\NUC029xAN.h"
#line 1 "D:\\NUC029xAN_BSPv3.00.003\\Library\\Device\\Nuvoton\\NUC029xAN\\Include\\system_NUC029xAN.h"
 









 







 
 
 











 




 





extern uint32_t SystemCoreClock;     
extern uint32_t CyclesPerUs;         
extern uint32_t PllClock;            

#line 65 "D:\\NUC029xAN_BSPv3.00.003\\Library\\Device\\Nuvoton\\NUC029xAN\\Include\\system_NUC029xAN.h"












 
extern void SystemInit(void);











 
extern void SystemCoreClockUpdate(void);







 
#line 96 "D:\\NUC029xAN_BSPv3.00.003\\Library\\Device\\Nuvoton\\NUC029xAN\\Include\\NUC029xAN.h"



#pragma anon_unions











 
extern void SystemInit(void);


 
 
 





 

 




 
typedef struct
{
    volatile uint32_t CR[2];

    volatile uint32_t SR;

} ACMP_T;




 

 















 












 











   
   


 



 
typedef struct
{
    



















 
    volatile const uint32_t ADDR[8];

    



























































 
    volatile uint32_t ADCR;

    



































 
    volatile uint32_t ADCHER;

    












































 
    volatile uint32_t ADCMPR[2];

    








































 
    volatile uint32_t ADSR;

    volatile const  uint32_t RESERVED0[4];

    volatile uint32_t ADTDCR;

} ADC_T;





 
 









 



























 






 


















 





















 


   
   



 



 
typedef struct
{
    








 
    volatile  int32_t DIVIDEND;

    









 
    volatile  int32_t DIVISOR;

    








 
    volatile  int32_t DIVQUO;

    








 
    volatile  int32_t DIVREM;

    














 
    volatile uint32_t DIVSTS;

} HDIV_T;





 







   
   



 



 
typedef struct
{
    



























 
    volatile uint32_t EBICON;

    



















 
    volatile uint32_t EXTIME;

    




 
    volatile uint32_t EBICON2;
} EBI_T;





 
 












 












 








   
   




 





 
typedef struct
{
    



































 
    volatile uint32_t ISPCON;

    









 
    volatile uint32_t ISPADR;

    









 
    volatile uint32_t ISPDAT;

    












 
    volatile uint32_t ISPCMD;

    











 
    volatile uint32_t ISPTRG;

    











 
    volatile const  uint32_t DFBADR;

    











 
    volatile uint32_t FATCON;

    volatile const uint32_t Reserved[9];

    























 
    volatile uint32_t ISPSTA;

} FMC_T;




 
 



















 









 



 



 











   
   

 




 
typedef struct
{
    







 
    volatile const  uint32_t PDID;

    









































 
    volatile uint32_t RSTSRC;

    



























 
    volatile uint32_t IPRSTC1;

    






















































 
    volatile uint32_t IPRSTC2;

    




 
    uint32_t RESERVED0[2];

    











































 
    volatile uint32_t BODCR;

    












 
    volatile uint32_t TEMPCR;

    




 
    uint32_t RESERVED1;

    












 
    volatile uint32_t PORCR;

    




 
    uint32_t RESERVED2[2];

    




































































 
    volatile uint32_t P0_MFP;

    




































































 
    volatile uint32_t P1_MFP;

    




































































 
    volatile uint32_t P2_MFP;

    
































































 
    volatile uint32_t P3_MFP;

    




























































 
    volatile uint32_t P4_MFP;

    




 
    uint32_t RESERVED3[47];

    


























 
    volatile uint32_t REGWRPROT;

} GCR_T;





 

 





















 












 


















































 





















 



 



 












 









 









 









 









 





   


typedef struct
{
    









































































































 
    volatile const  uint32_t IRQSRC[32];

    















 
    volatile uint32_t NMISEL;

    












 
    volatile uint32_t MCUIRQ;

} GCR_INT_T;




 

 





   


   


 



 
typedef struct
{
    















 
    volatile uint32_t  PMD;

    












 
    volatile uint32_t  OFFD;

    











 
    volatile uint32_t  DOUT;

    













 
    volatile uint32_t  DMASK;

    









 
    volatile uint32_t  PIN;

    















 
    volatile uint32_t  DBEN;

    















 
    volatile uint32_t  IMD;

    
























 
    volatile uint32_t  IEN;

    














 
    volatile uint32_t  ISRC;
} GPIO_T;

typedef struct
{
    






























 
    volatile uint32_t  DBNCECON;
} GPIO_DBNCECON_T;





 

 
























 



 



 



 



 



 



 






 



 








   
   


 




 
typedef struct
{
    
































 
    volatile uint32_t I2CON;

    













 
    volatile uint32_t I2CADDR0;

    








 
    volatile uint32_t I2CDAT;

    

















 
    volatile const  uint32_t I2CSTATUS;

    








 
    volatile uint32_t I2CLK;

    


















 
    volatile uint32_t I2CTOC;

    













 
    volatile uint32_t I2CADDR1;

    













 
    volatile uint32_t I2CADDR2;

    













 
    volatile uint32_t I2CADDR3;

    














 
    volatile uint32_t I2CADM0;

    














 
    volatile uint32_t I2CADM1;

    














 
    volatile uint32_t I2CADM2;

    














 
    volatile uint32_t I2CADM3;

    




 
    uint32_t RESERVED0[2];

    




 
    volatile uint32_t I2CWKUPCON;

    




 
    volatile uint32_t I2CWKUPSTS;

} I2C_T;




 

 


















 






 



 



 



 









 



 



 



   
   



 




 
typedef struct
{
    






















 
    volatile uint32_t PPR;

    























 
    volatile uint32_t CSR;

    








































































 
    volatile uint32_t PCR;

    
















 
    volatile uint32_t CNR0;

    
















 
    volatile uint32_t CMR0;

    








 
    volatile const  uint32_t PDR0;

    
















 
    volatile uint32_t CNR1;

    
















 
    volatile uint32_t CMR1;

    








 
    volatile const  uint32_t PDR1;

    
















 
    volatile uint32_t CNR2;

    
















 
    volatile uint32_t CMR2;

    








 
    volatile const  uint32_t PDR2;

    
















 
    volatile uint32_t CNR3;

    
















 
    volatile uint32_t CMR3;

    








 
    volatile const  uint32_t PDR3;

    




 
    volatile const uint32_t RESERVE0;

    


















 
    volatile uint32_t PIER;

    


















 
    volatile uint32_t PIIR;

    




 
    volatile const uint32_t    RESERVE1[2];

    








































































 
    volatile uint32_t CCR0;

    








































































 
    volatile uint32_t CCR2;

    








 
    volatile uint32_t CRLR0;

    








 
    volatile uint32_t CFLR0;

    








 
    volatile uint32_t CRLR1;

    








 
    volatile uint32_t CFLR1;

    








 
    volatile uint32_t CRLR2;

    








 
    volatile uint32_t CFLR2;

    








 
    volatile uint32_t CRLR3;

    








 
    volatile uint32_t CFLR3;

    






















 
    volatile uint32_t CAPENR;

    






















 
    volatile uint32_t POE;

    

























































 
    volatile uint32_t TCON;

    






















 
    volatile uint32_t TSTATUS;

    




 
    volatile const  uint32_t  RESERVE2[4];

    


















 
    volatile uint32_t PSCR;

} PWM_T;




 

 












 












 




























































 



 



 




 




































 
























 










































 










































 



 



 












 












 
























 












 











   
   




 



 
typedef struct
{
    


































































 
    volatile uint32_t CNTRL;

    







 
    volatile uint32_t DIVIDER;

    



































 
    volatile uint32_t SSR;

    




 
    volatile const  uint32_t RESERVE0;

    












 
    volatile const  uint32_t RX0;

    




 
    volatile const  uint32_t RESERVE1[2];

    




 
    volatile const  uint32_t RESERVE2;

    













 
    volatile  uint32_t TX0;

    




 
    volatile const  uint32_t RESERVE3[2];

    




 
    volatile const  uint32_t RESERVE4;

    




 
    volatile const  uint32_t RESERVE5;

    




 
    volatile const  uint32_t RESERVE6;

    




 
    volatile const  uint32_t RESERVE7;

    


































 
    volatile uint32_t CNTRL2;

    
































 
    volatile uint32_t FIFO_CTL;

    


















































 
    volatile uint32_t STATUS;

} SPI_T;




 

 
















































 






 















 





















 
























 



































   
   




 




 

typedef struct
{
    




















































 
    volatile uint32_t PWRCON;

    















 
    volatile uint32_t AHBCLK;

    
































































 
    volatile uint32_t APBCLK;

    























 
    volatile uint32_t CLKSTATUS;

    

























 
    volatile uint32_t CLKSEL0;

    





























































 
    volatile uint32_t CLKSEL1;

    












 
    volatile uint32_t CLKDIV;

    


























 
    volatile uint32_t CLKSEL2;

    

























 
    volatile uint32_t PLLCON;

    












 
    volatile uint32_t FRQDIV;

} CLK_T;




 

 




























 









 



























































 



















 






 

































 












 









 





















 





   
   




 



 
typedef struct
{
    

















































 
    volatile uint32_t  TCSR;

    














 
    volatile uint32_t  TCMPR;

    










 
    volatile uint32_t  TISR;

    









 
    volatile uint32_t  TDR;

    









 
    volatile uint32_t  TCAP;

    





































 
    volatile uint32_t  TEXCON;

    











 
    volatile uint32_t  TEXISR;
} TIMER_T;




 

 










































 



 






 



 



 





















 


   
   


 




 
typedef struct
{

    union
    {
        









         
        volatile uint32_t DATA;

        








 
        volatile uint32_t THR;

        








 
        volatile uint32_t RBR;
    };

    










































 
    volatile uint32_t IER;

    

































 
    volatile uint32_t FCR;

    































 
    volatile uint32_t LCR;

    




















 
    volatile uint32_t MCR;

    




















 
    volatile uint32_t MSR;

    




































































 
    volatile uint32_t FSR;

    















































































 
    volatile uint32_t ISR;

    














 
    volatile uint32_t TOR;

    


















 
    volatile uint32_t BAUD;

    














 
    volatile uint32_t IRCR;

    





































 
    volatile uint32_t ALT_CSR;

    












 
    volatile uint32_t FUN_SEL;
} UART_T;




 

 



 



 

































 















 


















 









 









 







































 










































 






 












 









 
























 


   
   



 



 
typedef struct
{
    















































 
    volatile uint32_t  WTCR;

    




 
    volatile uint32_t  WTCRALT;
} WDT_T;




 

 






























 


   
   


 



 
typedef struct
{
    










 
    volatile uint32_t  WWDTRLD;

    



























 
    volatile uint32_t  WWDTCR;

    











 
    volatile uint32_t  WWDTSR;

    








 
    volatile uint32_t  WWDTCVR;

} WWDT_T;




 

 



 















 






 


   
   
   


 
 
 



 
 






 
#line 6112 "D:\\NUC029xAN_BSPv3.00.003\\Library\\Device\\Nuvoton\\NUC029xAN\\Include\\NUC029xAN.h"









































   

 
 
 




 
#line 6169 "D:\\NUC029xAN_BSPv3.00.003\\Library\\Device\\Nuvoton\\NUC029xAN\\Include\\NUC029xAN.h"







































   



typedef volatile unsigned char  vu8;
typedef volatile unsigned long  vu32;
typedef volatile unsigned short vu16;




#line 6225 "D:\\NUC029xAN_BSPv3.00.003\\Library\\Device\\Nuvoton\\NUC029xAN\\Include\\NUC029xAN.h"

#line 6232 "D:\\NUC029xAN_BSPv3.00.003\\Library\\Device\\Nuvoton\\NUC029xAN\\Include\\NUC029xAN.h"













 
#line 6278 "D:\\NUC029xAN_BSPv3.00.003\\Library\\Device\\Nuvoton\\NUC029xAN\\Include\\NUC029xAN.h"


 











 
 
 
#line 1 "D:\\NUC029xAN_BSPv3.00.003\\Library\\StdDriver\\inc\\sys.h"
 









 




#line 1 "D:\\NUC029xAN_BSPv3.00.003\\Library\\Device\\Nuvoton\\NUC029xAN\\Include\\NUC029xAN.h"
 









 


















 


#line 6311 "D:\\NUC029xAN_BSPv3.00.003\\Library\\Device\\Nuvoton\\NUC029xAN\\Include\\NUC029xAN.h"

 

#line 17 "D:\\NUC029xAN_BSPv3.00.003\\Library\\StdDriver\\inc\\sys.h"









 



 



 

 
 
 
#line 57 "D:\\NUC029xAN_BSPv3.00.003\\Library\\StdDriver\\inc\\sys.h"


 
 
 
#line 68 "D:\\NUC029xAN_BSPv3.00.003\\Library\\StdDriver\\inc\\sys.h"


 
 
 




#line 83 "D:\\NUC029xAN_BSPv3.00.003\\Library\\StdDriver\\inc\\sys.h"

#line 90 "D:\\NUC029xAN_BSPv3.00.003\\Library\\StdDriver\\inc\\sys.h"

#line 97 "D:\\NUC029xAN_BSPv3.00.003\\Library\\StdDriver\\inc\\sys.h"

#line 104 "D:\\NUC029xAN_BSPv3.00.003\\Library\\StdDriver\\inc\\sys.h"











































#line 153 "D:\\NUC029xAN_BSPv3.00.003\\Library\\StdDriver\\inc\\sys.h"

#line 160 "D:\\NUC029xAN_BSPv3.00.003\\Library\\StdDriver\\inc\\sys.h"













































#line 211 "D:\\NUC029xAN_BSPv3.00.003\\Library\\StdDriver\\inc\\sys.h"






#line 223 "D:\\NUC029xAN_BSPv3.00.003\\Library\\StdDriver\\inc\\sys.h"

#line 230 "D:\\NUC029xAN_BSPv3.00.003\\Library\\StdDriver\\inc\\sys.h"







#line 243 "D:\\NUC029xAN_BSPv3.00.003\\Library\\StdDriver\\inc\\sys.h"












#line 261 "D:\\NUC029xAN_BSPv3.00.003\\Library\\StdDriver\\inc\\sys.h"











































   



 







 







 







 







 








 









 







 







 







 











 








 








 








 








 








 








 








 







 







 







 







 














 








 
static __inline void SYS_LockReg(void)
{
    ((GCR_T *) ((( uint32_t)0x50000000) + 0x00000))->REGWRPROT = 0;
}








 
static __inline void SYS_UnlockReg(void)
{
    while(((GCR_T *) ((( uint32_t)0x50000000) + 0x00000))->REGWRPROT != (1ul << 0))
    {
        ((GCR_T *) ((( uint32_t)0x50000000) + 0x00000))->REGWRPROT = 0x59;
        ((GCR_T *) ((( uint32_t)0x50000000) + 0x00000))->REGWRPROT = 0x16;
        ((GCR_T *) ((( uint32_t)0x50000000) + 0x00000))->REGWRPROT = 0x88;
    }
}





void SYS_ClearResetSrc(uint32_t u32Src);
uint32_t SYS_GetBODStatus(void);
uint32_t SYS_GetResetSrc(void);
uint32_t SYS_IsRegLocked(void);
uint32_t  SYS_ReadPDID(void);
void SYS_ResetChip(void);
void SYS_ResetCPU(void);
void SYS_ResetModule(uint32_t u32ModuleIndex);
void SYS_EnableBOD(int32_t i32Mode, uint32_t u32BODLevel);
void SYS_DisableBOD(void);


   

   

   






#line 6296 "D:\\NUC029xAN_BSPv3.00.003\\Library\\Device\\Nuvoton\\NUC029xAN\\Include\\NUC029xAN.h"
#line 1 "D:\\NUC029xAN_BSPv3.00.003\\Library\\StdDriver\\inc\\clk.h"
 









 




#line 17 "D:\\NUC029xAN_BSPv3.00.003\\Library\\StdDriver\\inc\\clk.h"




 



 



 







 
 
 
#line 49 "D:\\NUC029xAN_BSPv3.00.003\\Library\\StdDriver\\inc\\clk.h"


 
 
 
#line 95 "D:\\NUC029xAN_BSPv3.00.003\\Library\\StdDriver\\inc\\clk.h"


 
 
 
#line 114 "D:\\NUC029xAN_BSPv3.00.003\\Library\\StdDriver\\inc\\clk.h"


 
 
 





 
 
 














 
 
 
#line 153 "D:\\NUC029xAN_BSPv3.00.003\\Library\\StdDriver\\inc\\clk.h"
 
 
 




#line 180 "D:\\NUC029xAN_BSPv3.00.003\\Library\\StdDriver\\inc\\clk.h"



   




 







 
static __inline uint32_t CLK_GetPLLClockFreq(void)
{
    uint32_t u32PllFreq = 0, u32PllReg;
    uint32_t u32FIN, u32NF, u32NR, u32NO;
    uint8_t au8NoTbl[4] = {1, 2, 2, 4};

    u32PllReg = ((CLK_T *) ((( uint32_t)0x50000000) + 0x00200))->PLLCON;

    if(u32PllReg & ((1ul << 16) | (1ul << 18)))
        return 0;            

    if(u32PllReg & 0x00080000UL)
        u32FIN = (22118400UL);     
    else
        u32FIN = (12000000UL);      

    if(u32PllReg & (1ul << 17))
        return u32FIN;       

     
    u32NO = au8NoTbl[((u32PllReg & (3ul << 14)) >> 14)];
    u32NF = ((u32PllReg & (0x1FFul << 0)) >> 0) + 2;
    u32NR = ((u32PllReg & (0x1Ful << 9)) >> 9) + 2;

     
    u32PllFreq = (((u32FIN >> 2) * u32NF) / (u32NR * u32NO) << 2);

    return u32PllFreq;
}









 
static __inline void CLK_SysTickDelay(uint32_t us)
{
    ((SysTick_Type *) ((0xE000E000UL) + 0x0010UL) )->LOAD = us * CyclesPerUs;
    ((SysTick_Type *) ((0xE000E000UL) + 0x0010UL) )->VAL  = (0x00);
    ((SysTick_Type *) ((0xE000E000UL) + 0x0010UL) )->CTRL = (1UL << 2) | (1UL << 0);

     
    while((((SysTick_Type *) ((0xE000E000UL) + 0x0010UL) )->CTRL & (1UL << 16)) == 0);

     
    ((SysTick_Type *) ((0xE000E000UL) + 0x0010UL) )->CTRL = 0;
}








 
static __inline void CLK_SysTickLongDelay(uint32_t us)
{
    uint32_t delay;

     
    delay = 335544UL;

    do
    {
        if(us > delay)
        {
            us -= delay;
        }
        else
        {
            delay = us;
            us = 0UL;
        }

        ((SysTick_Type *) ((0xE000E000UL) + 0x0010UL) )->LOAD = delay * CyclesPerUs;
        ((SysTick_Type *) ((0xE000E000UL) + 0x0010UL) )->VAL  = (0x0UL);
        ((SysTick_Type *) ((0xE000E000UL) + 0x0010UL) )->CTRL = (1UL << 2) | (1UL << 0);

         
        while((((SysTick_Type *) ((0xE000E000UL) + 0x0010UL) )->CTRL & (1UL << 16)) == 0UL);

         
        ((SysTick_Type *) ((0xE000E000UL) + 0x0010UL) )->CTRL = 0UL;

    }
    while(us > 0UL);

}



void CLK_DisableCKO(void);
void CLK_EnableCKO(uint32_t u32ClkSrc, uint32_t u32ClkDiv, uint32_t u32ClkDivBy1En);
void CLK_PowerDown(void);
void CLK_Idle(void);
uint32_t CLK_GetHXTFreq(void);
uint32_t CLK_GetLXTFreq(void);
uint32_t CLK_GetHCLKFreq(void);
uint32_t CLK_GetPCLKFreq(void);
uint32_t CLK_GetCPUFreq(void);
uint32_t CLK_SetCoreClock(uint32_t u32Hclk);
void CLK_SetHCLK(uint32_t u32ClkSrc, uint32_t u32ClkDiv);
void CLK_SetModuleClock(uint32_t u32ModuleIdx, uint32_t u32ClkSrc, uint32_t u32ClkDiv);
void CLK_SetSysTickClockSrc(uint32_t u32ClkSrc);
void CLK_EnableXtalRC(uint32_t u32ClkMask);
void CLK_DisableXtalRC(uint32_t u32ClkMask);
void CLK_EnableModuleClock(uint32_t u32ModuleIdx);
void CLK_DisableModuleClock(uint32_t u32ModuleIdx);
uint32_t CLK_EnablePLL(uint32_t u32PllClkSrc, uint32_t u32PllFreq);
void CLK_DisablePLL(void);
uint32_t CLK_WaitClockReady(uint32_t u32ClkMask);
void CLK_EnableSysTick(uint32_t u32ClkSrc, uint32_t u32Count);
void CLK_DisableSysTick(void);


   

   

   







 
#line 6297 "D:\\NUC029xAN_BSPv3.00.003\\Library\\Device\\Nuvoton\\NUC029xAN\\Include\\NUC029xAN.h"
#line 1 "D:\\NUC029xAN_BSPv3.00.003\\Library\\StdDriver\\inc\\adc.h"
 








 











 



 



 
 
 
 

























 
 
 




 
 
 
#line 75 "D:\\NUC029xAN_BSPv3.00.003\\Library\\StdDriver\\inc\\adc.h"

 
 
 




 
 
 





 
 
 





 
 
 



 
 
 





   



 











 








 












 












 








 









 









 







 







 















 
#line 235 "D:\\NUC029xAN_BSPv3.00.003\\Library\\StdDriver\\inc\\adc.h"






 















 
#line 267 "D:\\NUC029xAN_BSPv3.00.003\\Library\\StdDriver\\inc\\adc.h"






 









 










 







 










 


void ADC_Open(ADC_T *adc,
              uint32_t u32InputMode,
              uint32_t u32OpMode,
              uint32_t u32ChMask);
void ADC_Close(ADC_T *adc);
void ADC_EnableHWTrigger(ADC_T *adc,
                         uint32_t u32Source,
                         uint32_t u32Param);
void ADC_DisableHWTrigger(ADC_T *adc);
void ADC_EnableInt(ADC_T *adc, uint32_t u32Mask);
void ADC_DisableInt(ADC_T *adc, uint32_t u32Mask);



   

   

   







 
#line 6298 "D:\\NUC029xAN_BSPv3.00.003\\Library\\Device\\Nuvoton\\NUC029xAN\\Include\\NUC029xAN.h"
#line 1 "D:\\NUC029xAN_BSPv3.00.003\\Library\\StdDriver\\inc\\ebi.h"
 








 











 



 



 
 
 
 



 
 
 



 
 
 
#line 52 "D:\\NUC029xAN_BSPv3.00.003\\Library\\StdDriver\\inc\\ebi.h"

#line 60 "D:\\NUC029xAN_BSPv3.00.003\\Library\\StdDriver\\inc\\ebi.h"

   




 









 











 










 











 










 











 


void EBI_Open(uint32_t u32Bank, uint32_t u32DataWidth, uint32_t u32TimingClass, uint32_t u32BusMode, uint32_t u32CSActiveLevel);
void EBI_Close(uint32_t u32Bank);
void EBI_SetBusTiming(uint32_t u32Bank, uint32_t u32TimingConfig, uint32_t u32MclkDiv);

   

   

   







 
#line 6299 "D:\\NUC029xAN_BSPv3.00.003\\Library\\Device\\Nuvoton\\NUC029xAN\\Include\\NUC029xAN.h"
#line 1 "D:\\NUC029xAN_BSPv3.00.003\\Library\\StdDriver\\inc\\fmc.h"
 









 



#line 16 "D:\\NUC029xAN_BSPv3.00.003\\Library\\StdDriver\\inc\\fmc.h"









 



 



 


 
 
 







 
 
 



 
 
 
#line 62 "D:\\NUC029xAN_BSPv3.00.003\\Library\\StdDriver\\inc\\fmc.h"


   



 

 
 
 









 












 













 













 














 











 













 












 













 















 














 



 
 
 











 
static __inline void FMC_Write(uint32_t u32addr, uint32_t u32data)
{
    ((FMC_T *) ((( uint32_t)0x50000000) + 0x0C000))->ISPCMD = 0x21;    
    ((FMC_T *) ((( uint32_t)0x50000000) + 0x0C000))->ISPADR = u32addr;               
    ((FMC_T *) ((( uint32_t)0x50000000) + 0x0C000))->ISPDAT = u32data;               
    ((FMC_T *) ((( uint32_t)0x50000000) + 0x0C000))->ISPTRG = 0x1;                   
    __isb(0xF);                             
    while(((FMC_T *) ((( uint32_t)0x50000000) + 0x0C000))->ISPTRG);                  
}










 
static __inline uint32_t FMC_Read(uint32_t u32addr)
{
    ((FMC_T *) ((( uint32_t)0x50000000) + 0x0C000))->ISPCMD = 0x00;  
    ((FMC_T *) ((( uint32_t)0x50000000) + 0x0C000))->ISPADR = u32addr;          
    ((FMC_T *) ((( uint32_t)0x50000000) + 0x0C000))->ISPTRG = 0x1;              
    __isb(0xF);                        
    while(((FMC_T *) ((( uint32_t)0x50000000) + 0x0C000))->ISPTRG);             

    return ((FMC_T *) ((( uint32_t)0x50000000) + 0x0C000))->ISPDAT;
}













 
static __inline int32_t FMC_Erase(uint32_t u32addr)
{
    ((FMC_T *) ((( uint32_t)0x50000000) + 0x0C000))->ISPCMD = 0x22;  
    ((FMC_T *) ((( uint32_t)0x50000000) + 0x0C000))->ISPADR = u32addr;                
    ((FMC_T *) ((( uint32_t)0x50000000) + 0x0C000))->ISPTRG = 0x1;                    
    __isb(0xF);                              
    while(((FMC_T *) ((( uint32_t)0x50000000) + 0x0C000))->ISPTRG);                   

     
    if(((FMC_T *) ((( uint32_t)0x50000000) + 0x0C000))->ISPCON & (1ul << 6))
    {
        ((FMC_T *) ((( uint32_t)0x50000000) + 0x0C000))->ISPCON |= (1ul << 6);
        return -1;
    }
    return 0;
}










 
static __inline uint32_t FMC_ReadUID(uint8_t u8index)
{
    ((FMC_T *) ((( uint32_t)0x50000000) + 0x0C000))->ISPCMD = 0x04;  
    ((FMC_T *) ((( uint32_t)0x50000000) + 0x0C000))->ISPADR = (u8index << 2);       
    ((FMC_T *) ((( uint32_t)0x50000000) + 0x0C000))->ISPTRG = 0x1;                  
    __isb(0xF);                            
    while(((FMC_T *) ((( uint32_t)0x50000000) + 0x0C000))->ISPTRG);                 

    return ((FMC_T *) ((( uint32_t)0x50000000) + 0x0C000))->ISPDAT;
}











 
static __inline uint32_t FMC_ReadCID(void)
{
    ((FMC_T *) ((( uint32_t)0x50000000) + 0x0C000))->ISPCMD = 0x0B;            
    ((FMC_T *) ((( uint32_t)0x50000000) + 0x0C000))->ISPADR = 0x0;                            
    ((FMC_T *) ((( uint32_t)0x50000000) + 0x0C000))->ISPTRG = (1ul << 0);           
    __isb(0xF);                                      
    while(((FMC_T *) ((( uint32_t)0x50000000) + 0x0C000))->ISPTRG & (1ul << 0)) ;   

    return ((FMC_T *) ((( uint32_t)0x50000000) + 0x0C000))->ISPDAT;
}











 
static __inline uint32_t FMC_ReadPID(void)
{
    ((FMC_T *) ((( uint32_t)0x50000000) + 0x0C000))->ISPCMD = 0x0C;           
    ((FMC_T *) ((( uint32_t)0x50000000) + 0x0C000))->ISPADR = 0x04;                          
    ((FMC_T *) ((( uint32_t)0x50000000) + 0x0C000))->ISPTRG = (1ul << 0);          
    __isb(0xF);                                     
    while(((FMC_T *) ((( uint32_t)0x50000000) + 0x0C000))->ISPTRG & (1ul << 0));   

    return ((FMC_T *) ((( uint32_t)0x50000000) + 0x0C000))->ISPDAT;
}










 
static __inline uint32_t FMC_ReadUCID(uint32_t u32Index)
{
    ((FMC_T *) ((( uint32_t)0x50000000) + 0x0C000))->ISPCMD = 0x04;           
    ((FMC_T *) ((( uint32_t)0x50000000) + 0x0C000))->ISPADR = (0x04 * u32Index) + 0x10;      
    ((FMC_T *) ((( uint32_t)0x50000000) + 0x0C000))->ISPTRG = (1ul << 0);          
    __isb(0xF);                                     
    while(((FMC_T *) ((( uint32_t)0x50000000) + 0x0C000))->ISPTRG & (1ul << 0));   

    return ((FMC_T *) ((( uint32_t)0x50000000) + 0x0C000))->ISPDAT;
}















 
static __inline void FMC_SetVectorPageAddr(uint32_t u32PageAddr)
{
    ((FMC_T *) ((( uint32_t)0x50000000) + 0x0C000))->ISPCMD = 0x2e;  
    ((FMC_T *) ((( uint32_t)0x50000000) + 0x0C000))->ISPADR = u32PageAddr;        
    ((FMC_T *) ((( uint32_t)0x50000000) + 0x0C000))->ISPTRG = 0x1;                
    __isb(0xF);                          
    while(((FMC_T *) ((( uint32_t)0x50000000) + 0x0C000))->ISPTRG);               
}














 
static __inline uint32_t FMC_GetVECMAP(void)
{
    return (((FMC_T *) ((( uint32_t)0x50000000) + 0x0C000))->ISPSTA & (0xffful << 9));
}

extern void FMC_Open(void);
extern void FMC_Close(void);
extern void FMC_EnableAPUpdate(void);
extern void FMC_DisableAPUpdate(void);
extern void FMC_EnableConfigUpdate(void);
extern void FMC_DisableConfigUpdate(void);
extern void FMC_EnableLDUpdate(void);
extern void FMC_DisableLDUpdate(void);
extern int32_t FMC_ReadConfig(uint32_t *u32Config, uint32_t u32Count);
extern int32_t FMC_WriteConfig(uint32_t *u32Config, uint32_t u32Count);
extern void FMC_SetBootSource(int32_t i32BootSrc);
extern int32_t FMC_GetBootSource(void);
extern uint32_t FMC_ReadDataFlashBaseAddr(void);

   

   

   








#line 6300 "D:\\NUC029xAN_BSPv3.00.003\\Library\\Device\\Nuvoton\\NUC029xAN\\Include\\NUC029xAN.h"
#line 1 "D:\\NUC029xAN_BSPv3.00.003\\Library\\StdDriver\\inc\\gpio.h"
 









 











 



 



 


 
 
 





 
 
 






 
 
 



 
 
 






#line 82 "D:\\NUC029xAN_BSPv3.00.003\\Library\\StdDriver\\inc\\gpio.h"














 
#line 138 "D:\\NUC029xAN_BSPv3.00.003\\Library\\StdDriver\\inc\\gpio.h"
   




 











 












 











 












 












 












 












 













 



















 










 











 










 













 












 














 












 



void GPIO_SetMode(GPIO_T *port, uint32_t u32PinMask, uint32_t u32Mode);
void GPIO_EnableInt(GPIO_T *port, uint32_t u32Pin, uint32_t u32IntAttribs);
void GPIO_DisableInt(GPIO_T *port, uint32_t u32Pin);


   

   

   







 
#line 6301 "D:\\NUC029xAN_BSPv3.00.003\\Library\\Device\\Nuvoton\\NUC029xAN\\Include\\NUC029xAN.h"
#line 1 "D:\\NUC029xAN_BSPv3.00.003\\Library\\StdDriver\\inc\\i2c.h"
 









 



#line 16 "D:\\NUC029xAN_BSPv3.00.003\\Library\\StdDriver\\inc\\i2c.h"









 



 



 

 
 
 
#line 49 "D:\\NUC029xAN_BSPv3.00.003\\Library\\StdDriver\\inc\\i2c.h"




   



 









 










 










 










 










 











 










 











 











 










 


void I2C_ClearTimeoutFlag(I2C_T *i2c);
void I2C_Close(I2C_T *i2c);
void I2C_Trigger(I2C_T *i2c, uint8_t u8Start, uint8_t u8Stop, uint8_t u8Si, uint8_t u8Ack);
void I2C_DisableInt(I2C_T *i2c);
void I2C_EnableInt(I2C_T *i2c);
uint32_t I2C_GetBusClockFreq(I2C_T *i2c);
uint32_t I2C_SetBusClockFreq(I2C_T *i2c, uint32_t u32BusClock);
uint32_t I2C_GetIntFlag(I2C_T *i2c);
uint32_t I2C_GetStatus(I2C_T *i2c);
uint32_t I2C_Open(I2C_T *i2c, uint32_t u32BusClock);
uint8_t I2C_GetData(I2C_T *i2c);
void I2C_SetSlaveAddr(I2C_T *i2c, uint8_t u8SlaveNo, uint8_t u8SlaveAddr, uint8_t u8GCMode);
void I2C_SetSlaveAddrMask(I2C_T *i2c, uint8_t u8SlaveNo, uint8_t u8SlaveAddrMask);
uint32_t I2C_SetClockBusFreq(I2C_T *i2c, uint32_t u32BusClock);
void I2C_EnableTimeout(I2C_T *i2c, uint8_t u8LongTimeout);
void I2C_DisableTimeout(I2C_T *i2c);
void I2C_EnableWakeup(I2C_T *i2c);
void I2C_DisableWakeup(I2C_T *i2c);
void I2C_SetData(I2C_T *i2c, uint8_t u8Data);

   

   

   

#line 6302 "D:\\NUC029xAN_BSPv3.00.003\\Library\\Device\\Nuvoton\\NUC029xAN\\Include\\NUC029xAN.h"
#line 1 "D:\\NUC029xAN_BSPv3.00.003\\Library\\StdDriver\\inc\\pwm.h"
 








 











 



 



 
#line 47 "D:\\NUC029xAN_BSPv3.00.003\\Library\\StdDriver\\inc\\pwm.h"
 
 
 






   




 










 
#line 81 "D:\\NUC029xAN_BSPv3.00.003\\Library\\StdDriver\\inc\\pwm.h"










 
#line 100 "D:\\NUC029xAN_BSPv3.00.003\\Library\\StdDriver\\inc\\pwm.h"










 
#line 120 "D:\\NUC029xAN_BSPv3.00.003\\Library\\StdDriver\\inc\\pwm.h"









 










 













 

















 













 














 














 
#line 225 "D:\\NUC029xAN_BSPv3.00.003\\Library\\StdDriver\\inc\\pwm.h"


uint32_t PWM_ConfigCaptureChannel(PWM_T *pwm,
                                  uint32_t u32ChannelNum,
                                  uint32_t u32UnitTimeNsec,
                                  uint32_t u32CaptureEdge);
uint32_t PWM_ConfigOutputChannel(PWM_T *pwm,
                                 uint32_t u32ChannelNum,
                                 uint32_t u32Frequncy,
                                 uint32_t u32DutyCycle);
void PWM_Start(PWM_T *pwm, uint32_t u32ChannelMask);
void PWM_Stop(PWM_T *pwm, uint32_t u32ChannelMask);
void PWM_ForceStop(PWM_T *pwm, uint32_t u32ChannelMask);
void PWM_EnableADCTrigger(PWM_T *pwm, uint32_t u32ChannelNum, uint32_t u32Condition);
void PWM_DisableADCTrigger(PWM_T *pwm, uint32_t u32ChannelNum);
void PWM_ClearADCTriggerFlag(PWM_T *pwm, uint32_t u32ChannelNum, uint32_t u32Condition);
uint32_t PWM_GetADCTriggerFlag(PWM_T *pwm, uint32_t u32ChannelNum);
void PWM_EnableCapture(PWM_T *pwm, uint32_t u32ChannelMask);
void PWM_DisableCapture(PWM_T *pwm, uint32_t u32ChannelMask);
void PWM_EnableOutput(PWM_T *pwm, uint32_t u32ChannelMask);
void PWM_DisableOutput(PWM_T *pwm, uint32_t u32ChannelMask);
void PWM_EnableDeadZone(PWM_T *pwm, uint32_t u32ChannelNum, uint32_t u32Duration);
void PWM_DisableDeadZone(PWM_T *pwm, uint32_t u32ChannelNum);
void PWM_EnableCaptureInt(PWM_T *pwm, uint32_t u32ChannelNum, uint32_t u32Edge);
void PWM_DisableCaptureInt(PWM_T *pwm, uint32_t u32ChannelNum, uint32_t u32Edge);
void PWM_ClearCaptureIntFlag(PWM_T *pwm, uint32_t u32ChannelNum, uint32_t u32Edge);
uint32_t PWM_GetCaptureIntFlag(PWM_T *pwm, uint32_t u32ChannelNum);
void PWM_EnableDutyInt(PWM_T *pwm, uint32_t u32ChannelNum, uint32_t u32IntDutyType);
void PWM_DisableDutyInt(PWM_T *pwm, uint32_t u32ChannelNum);
void PWM_ClearDutyIntFlag(PWM_T *pwm, uint32_t u32ChannelNum);
uint32_t PWM_GetDutyIntFlag(PWM_T *pwm, uint32_t u32ChannelNum);
void PWM_EnablePeriodInt(PWM_T *pwm, uint32_t u32ChannelNum,  uint32_t u32IntPeriodType);
void PWM_DisablePeriodInt(PWM_T *pwm, uint32_t u32ChannelNum);
void PWM_ClearPeriodIntFlag(PWM_T *pwm, uint32_t u32ChannelNum);
uint32_t PWM_GetPeriodIntFlag(PWM_T *pwm, uint32_t u32ChannelNum);



   

   

   







 
#line 6303 "D:\\NUC029xAN_BSPv3.00.003\\Library\\Device\\Nuvoton\\NUC029xAN\\Include\\NUC029xAN.h"
#line 1 "D:\\NUC029xAN_BSPv3.00.003\\Library\\StdDriver\\inc\\spi.h"
 








 











 



 



 













#line 50 "D:\\NUC029xAN_BSPv3.00.003\\Library\\StdDriver\\inc\\spi.h"







   




 






 







 







 







 







 







 








 








 








 







 







 








 








 







 







 







 







 









 







 







 








 








 







 



 
uint32_t SPI_Open(SPI_T *spi, uint32_t u32MasterSlave, uint32_t u32SPIMode, uint32_t u32DataWidth, uint32_t u32BusClock);
void SPI_Close(SPI_T *spi);
void SPI_ClearRxFIFO(SPI_T *spi);
void SPI_ClearTxFIFO(SPI_T *spi);
void SPI_DisableAutoSS(SPI_T *spi);
void SPI_EnableAutoSS(SPI_T *spi, uint32_t u32SSPinMask, uint32_t u32ActiveLevel);
uint32_t SPI_SetBusClock(SPI_T *spi, uint32_t u32BusClock);
void SPI_EnableFIFO(SPI_T *spi, uint32_t u32TxThreshold, uint32_t u32RxThreshold);
void SPI_DisableFIFO(SPI_T *spi);
uint32_t SPI_GetBusClock(SPI_T *spi);
void SPI_EnableInt(SPI_T *spi, uint32_t u32Mask);
void SPI_DisableInt(SPI_T *spi, uint32_t u32Mask);
uint32_t SPI_GetIntFlag(SPI_T *spi, uint32_t u32Mask);
void SPI_ClearIntFlag(SPI_T *spi, uint32_t u32Mask);
uint32_t SPI_GetStatus(SPI_T *spi, uint32_t u32Mask);

   

   

   







 
#line 6304 "D:\\NUC029xAN_BSPv3.00.003\\Library\\Device\\Nuvoton\\NUC029xAN\\Include\\NUC029xAN.h"
#line 1 "D:\\NUC029xAN_BSPv3.00.003\\Library\\StdDriver\\inc\\timer.h"
 








 











 



 



 

#line 48 "D:\\NUC029xAN_BSPv3.00.003\\Library\\StdDriver\\inc\\timer.h"

   




 













 












 











 













 










 
static __inline void TIMER_Start(TIMER_T *timer)
{
    timer->TCSR |= (1ul << 30);
}









 
static __inline void TIMER_Stop(TIMER_T *timer)
{
    timer->TCSR &= ~(1ul << 30);
}











 
static __inline void TIMER_EnableWakeup(TIMER_T *timer)
{
    timer->TCSR |= (1ul << 23);
}









 
static __inline void TIMER_DisableWakeup(TIMER_T *timer)
{
    timer->TCSR &= ~(1ul << 23);
}









 
static __inline void TIMER_EnableCaptureDebounce(TIMER_T *timer)
{
    timer->TEXCON |= (1ul << 6);
}









 
static __inline void TIMER_DisableCaptureDebounce(TIMER_T *timer)
{
    timer->TEXCON &= ~(1ul << 6);
}









 
static __inline void TIMER_EnableEventCounterDebounce(TIMER_T *timer)
{
    timer->TEXCON |= (1ul << 7);
}









 
static __inline void TIMER_DisableEventCounterDebounce(TIMER_T *timer)
{
    timer->TEXCON &= ~(1ul << 7);
}









 
static __inline void TIMER_EnableInt(TIMER_T *timer)
{
    timer->TCSR |= (1ul << 29);
}









 
static __inline void TIMER_DisableInt(TIMER_T *timer)
{
    timer->TCSR &= ~(1ul << 29);
}









 
static __inline void TIMER_EnableCaptureInt(TIMER_T *timer)
{
    timer->TEXCON |= (1ul << 5);
}









 
static __inline void TIMER_DisableCaptureInt(TIMER_T *timer)
{
    timer->TEXCON &= ~(1ul << 5);
}










 
static __inline uint32_t TIMER_GetIntFlag(TIMER_T *timer)
{
    return (timer->TISR & (1ul << 0) ? 1 : 0);
}









 
static __inline void TIMER_ClearIntFlag(TIMER_T *timer)
{
    timer->TISR = (1ul << 0);
}










 
static __inline uint32_t TIMER_GetCaptureIntFlag(TIMER_T *timer)
{
    return timer->TEXISR;
}









 
static __inline void TIMER_ClearCaptureIntFlag(TIMER_T *timer)
{
    timer->TEXISR = (1ul << 0);
}










 
static __inline uint32_t TIMER_GetWakeupFlag(TIMER_T *timer)
{
    return (timer->TISR & (1ul << 1) ? 1 : 0);
}









 
static __inline void TIMER_ClearWakeupFlag(TIMER_T *timer)
{
    timer->TISR = (1ul << 1);
}









 
static __inline uint32_t TIMER_GetCaptureData(TIMER_T *timer)
{
    return timer->TCAP;
}









 
static __inline uint32_t TIMER_GetCounter(TIMER_T *timer)
{
    return timer->TDR;
}

uint32_t TIMER_Open(TIMER_T *timer, uint32_t u32Mode, uint32_t u32Freq);
void TIMER_Close(TIMER_T *timer);
void TIMER_Delay(TIMER_T *timer, uint32_t u32Usec);
void TIMER_EnableCapture(TIMER_T *timer, uint32_t u32CapMode, uint32_t u32Edge);
void TIMER_DisableCapture(TIMER_T *timer);
void TIMER_EnableEventCounter(TIMER_T *timer, uint32_t u32Edge);
void TIMER_DisableEventCounter(TIMER_T *timer);
uint32_t TIMER_GetModuleClock(TIMER_T *timer);

   

   

   







 
#line 6305 "D:\\NUC029xAN_BSPv3.00.003\\Library\\Device\\Nuvoton\\NUC029xAN\\Include\\NUC029xAN.h"
#line 1 "D:\\NUC029xAN_BSPv3.00.003\\Library\\StdDriver\\inc\\wdt.h"
 








 











 



 



 
 
 
 
#line 42 "D:\\NUC029xAN_BSPv3.00.003\\Library\\StdDriver\\inc\\wdt.h"

 
 
 





   




 









 










 










 











 











 











 













 










 
static __inline void WDT_Close(void)
{
    ((WDT_T *) ((( uint32_t)0x40000000) + 0x4000))->WTCR = 0;
    return;
}









 
static __inline void WDT_EnableInt(void)
{
    ((WDT_T *) ((( uint32_t)0x40000000) + 0x4000))->WTCR |= (1ul << 6);
    return;
}









 
static __inline void WDT_DisableInt(void)
{
    
    ((WDT_T *) ((( uint32_t)0x40000000) + 0x4000))->WTCR &= ~((1ul << 6) | (1ul << 2) | (1ul << 3));
    return;
}

void WDT_Open(uint32_t u32TimeoutInterval, uint32_t u32ResetDelay, uint32_t u32EnableReset, uint32_t u32EnableWakeup);

   

   

   







 
#line 6306 "D:\\NUC029xAN_BSPv3.00.003\\Library\\Device\\Nuvoton\\NUC029xAN\\Include\\NUC029xAN.h"
#line 1 "D:\\NUC029xAN_BSPv3.00.003\\Library\\StdDriver\\inc\\wwdt.h"
 








 











 



 



 
 
 
 
#line 50 "D:\\NUC029xAN_BSPv3.00.003\\Library\\StdDriver\\inc\\wwdt.h"



   




 









 










 











 











 










 













 


void WWDT_Open(uint32_t u32PreScale, uint32_t u32CmpValue, uint32_t u32EnableInt);

   

   

   







 
#line 6307 "D:\\NUC029xAN_BSPv3.00.003\\Library\\Device\\Nuvoton\\NUC029xAN\\Include\\NUC029xAN.h"
#line 1 "D:\\NUC029xAN_BSPv3.00.003\\Library\\StdDriver\\inc\\uart.h"
 








 



#line 15 "D:\\NUC029xAN_BSPv3.00.003\\Library\\StdDriver\\inc\\uart.h"









 



 



 

 
 
 




 
 
 











 
 
 
















 
 
 



 
 
 



 
 
 





 
 
 




   




 











 











 












 










 












 












 











 











 











 












 











 












 












 




















 




















 



























 











 
static __inline void UART_CLEAR_RTS(UART_T* uart)
{
    uart->MCR |= (1ul << 9);
    uart->MCR &= ~(1ul << 1);
}








 
static __inline void UART_SET_RTS(UART_T* uart)
{
    uart->MCR |= (1ul << 9) | (1ul << 1);
}










 












 



void UART_ClearIntFlag(UART_T* uart, uint32_t u32InterruptFlag);
void UART_Close(UART_T* uart);
void UART_DisableFlowCtrl(UART_T* uart);
void UART_DisableInt(UART_T*  uart, uint32_t u32InterruptFlag);
void UART_EnableFlowCtrl(UART_T* uart);
void UART_EnableInt(UART_T*  uart, uint32_t u32InterruptFlag);
void UART_Open(UART_T* uart, uint32_t u32baudrate);
uint32_t UART_Read(UART_T* uart, uint8_t *pu8RxBuf, uint32_t u32ReadBytes);
void UART_SetLine_Config(UART_T* uart, uint32_t u32baudrate, uint32_t u32data_width, uint32_t u32parity, uint32_t  u32stop_bits);
void UART_SetTimeoutCnt(UART_T* uart, uint32_t u32TOC);
void UART_SelectIrDAMode(UART_T* uart, uint32_t u32Buadrate, uint32_t u32Direction);
void UART_SelectRS485Mode(UART_T* uart, uint32_t u32Mode, uint32_t u32Addr);
void UART_SelectLINMode(UART_T* uart, uint32_t u32Mode, uint32_t u32BreakLength);
uint32_t UART_Write(UART_T* uart, uint8_t *pu8TxBuf, uint32_t u32WriteBytes);


   

   

   







 

#line 6308 "D:\\NUC029xAN_BSPv3.00.003\\Library\\Device\\Nuvoton\\NUC029xAN\\Include\\NUC029xAN.h"
#line 1 "D:\\NUC029xAN_BSPv3.00.003\\Library\\StdDriver\\inc\\hdiv.h"
 









 














 
static __inline int32_t HDIV_Div(int32_t x, int16_t y)
{
    uint32_t *p32;

    p32 = (uint32_t *)((( uint32_t)0x50000000) + 0x14000);
    *p32++ = x;
    *p32++ = y;
    return *p32;
}











 
static __inline int16_t HDIV_Mod(int32_t x, int16_t y)
{
    uint32_t *p32;

    p32 = (uint32_t *)((( uint32_t)0x50000000) + 0x14000);
    *p32++ = x;
    *p32++ = y;
    return p32[1];
}





#line 6309 "D:\\NUC029xAN_BSPv3.00.003\\Library\\Device\\Nuvoton\\NUC029xAN\\Include\\NUC029xAN.h"
#line 1 "D:\\NUC029xAN_BSPv3.00.003\\Library\\StdDriver\\inc\\acmp.h"
 








 











 



 



 

 
 
 
#line 44 "D:\\NUC029xAN_BSPv3.00.003\\Library\\StdDriver\\inc\\acmp.h"

   




 







 








 











 








 








 








 








 









 








 








 








 








 



 
void ACMP_Open(ACMP_T *, uint32_t u32ChNum, uint32_t u32NegSrc, uint32_t u32HysteresisEn);
void ACMP_Close(ACMP_T *, uint32_t u32ChNum);

   

   

   







 
#line 6310 "D:\\NUC029xAN_BSPv3.00.003\\Library\\Device\\Nuvoton\\NUC029xAN\\Include\\NUC029xAN.h"


 

#line 16 "D:\\NUC029xAN_BSPv3.00.003\\Library\\StdDriver\\src\\retarget.c"




 
#pragma import _printf_widthprec



 
 
 

struct __FILE
{
    int handle;  
};

FILE __stdout;
FILE __stdin;

enum { r0, r1, r2, r3, r12, lr, pc, psr};






 
static void stackDump(uint32_t stack[])
{   
    printf("r0  = 0x%x\n", stack[r0]);
    printf("r1  = 0x%x\n", stack[r1]);
    printf("r2  = 0x%x\n", stack[r2]);
    printf("r3  = 0x%x\n", stack[r3]);
    printf("r12 = 0x%x\n", stack[r12]);
    printf("lr  = 0x%x\n", stack[lr]);
    printf("pc  = 0x%x\n", stack[pc]);
    printf("psr = 0x%x\n", stack[psr]);
}






 
void Hard_Fault_Handler(uint32_t stack[])
{
    printf("In Hard Fault Handler\n");

    stackDump(stack);

    
    while(1);
    
}

 
 
 


 
static char g_buf[16];
static char g_buf_len = 0;

#line 227 "D:\\NUC029xAN_BSPv3.00.003\\Library\\StdDriver\\src\\retarget.c"







 
__asm int32_t HardFault_Handler(void)
{
    MOV     R0, LR
    LSLS    R0, #29               
    BMI     SP_is_PSP             
    MRS     R0, MSP               
    B       SP_Read_Ready
SP_is_PSP
    MRS     R0, PSP               

SP_Read_Ready
    LDR     R1, [R0, #24]         
    LDRH    R3, [R1]              
    LDR     R2, =0xBEAB           
    CMP     R3, R2                
    BNE     HardFault_Handler_Ret 

    ADDS    R1, #4                
    STR     R1, [R0, #24]         

    BX      LR                    
HardFault_Handler_Ret

     
    MOVS    r0, #4
    MOV     r1, LR
    TST     r0, r1                          
    BEQ     Stack_Use_MSP                   
    MRS     R0, PSP ;stack use PSP          
    B       Get_LR_and_Branch
Stack_Use_MSP
    MRS     R0, MSP ; stack use MSP         
Get_LR_and_Branch
    MOV     R1, LR ; LR current value       
    LDR     R2,=__cpp(Hard_Fault_Handler)   
    BX      R2

    B       .

                 ALIGN
}










 
__asm int32_t SH_DoCommand(int32_t n32In_R0, int32_t n32In_R1, int32_t *pn32Out_R0)
{
    BKPT   0xAB          
    
    
    B      SH_ICE

SH_HardFault             
    MOVS   R0, #0        
    BX     lr            

SH_ICE                   
    
    CMP    R2, #0
    BEQ    SH_End
    STR    R0, [R2]      

SH_End
    MOVS   R0, #1        
    BX     lr            
}



#line 383 "D:\\NUC029xAN_BSPv3.00.003\\Library\\StdDriver\\src\\retarget.c"










 

void SendChar_ToUART(int ch)
{

    while(((UART_T *) ((( uint32_t)0x40000000) + 0x50000))->FSR & (1ul << 23));
    ((UART_T *) ((( uint32_t)0x40000000) + 0x50000))->DATA = ch;
    if(ch == '\n')
    {
        while(((UART_T *) ((( uint32_t)0x40000000) + 0x50000))->FSR & (1ul << 23));
        ((UART_T *) ((( uint32_t)0x40000000) + 0x50000))->DATA = '\r';
    }
}









 
void SendChar(int ch)
{

    g_buf[g_buf_len++] = ch;
    g_buf[g_buf_len] = '\0';
    if(g_buf_len + 1 >= sizeof(g_buf) || ch == '\n' || ch == '\0')
    {
         
        if(SH_DoCommand(0x04, (int)g_buf, 0) != 0)
        {
            g_buf_len = 0;
            return;
        }
        else
        {
            g_buf_len = 0;
        }
    }



}









 
char GetChar(void)
{


    int nRet;
    while(SH_DoCommand(0x101, 0, &nRet) != 0)
    {
        if(nRet != 0)
        {
            SH_DoCommand(0x07, 0, &nRet);
            return (char)nRet;
        }
    }
#line 469 "D:\\NUC029xAN_BSPv3.00.003\\Library\\StdDriver\\src\\retarget.c"
    return (0);
#line 481 "D:\\NUC029xAN_BSPv3.00.003\\Library\\StdDriver\\src\\retarget.c"
}










 

int kbhit(void)
{
    return !((((UART_T *) ((( uint32_t)0x40000000) + 0x50000))->FSR & (1ul << 14)) == 0);
}









 

int IsDebugFifoEmpty(void)
{
    return ((((UART_T *) ((( uint32_t)0x40000000) + 0x50000))->FSR & (1ul << 28)) != 0);
}









 

void _ttywrch(int ch)
{
    SendChar(ch);
    return;
}


















 

int fputc(int ch, FILE *stream)
{
    SendChar(ch);
    return ch;
}











 

int fgetc(FILE *stream)
{
    return (GetChar());
}














 

int ferror(FILE *stream)
{
    return (-1);
}

#line 607 "D:\\NUC029xAN_BSPv3.00.003\\Library\\StdDriver\\src\\retarget.c"
void _sys_exit(int return_code)
{

     
    if(SH_DoCommand(0x18, 0x20026, 0) == 0)
    {
         
        while(IsDebugFifoEmpty() == 0);
    }
label:
    goto label;   
}







